package com.hsc.yalebao.adapter;

import android.content.Context;
import android.graphics.Bitmap.Config;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
import com.facebook.drawee.controller.AbstractDraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hsc.yalebao.model.ChatMsgEntity;
import com.hsc.yalebao.tools.DateUtil;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.RoundImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.DisplayImageOptions.Builder;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import java.io.PrintStream;
import java.util.List;

public class ChatMsgViewAdpater extends BaseAdapter
{
  private static final String TAG = ChatMsgViewAdpater.class.getSimpleName();
  private Context context;
  int count = 0;
  public List<ChatMsgEntity> data;
  private ImageSize mImageSize;
  private LayoutInflater mInflater;
  private DisplayImageOptions options;

  public ChatMsgViewAdpater(Context paramContext, List<ChatMsgEntity> paramList)
  {
    this.context = paramContext;
    this.data = paramList;
    this.mInflater = LayoutInflater.from(paramContext);
    this.mImageSize = new ImageSize(400, 200);
    this.options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).resetViewBeforeLoading(true).showImageOnFail(0).bitmapConfig(Bitmap.Config.RGB_565).build();
  }

  public int getCount()
  {
    return this.count;
  }

  public Object getItem(int paramInt)
  {
    return this.data.get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public int getItemViewType(int paramInt)
  {
    if (((ChatMsgEntity)this.data.get(paramInt)).isComMsg() == 0)
      return 0;
    return 1;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    ChatMsgEntity localChatMsgEntity = (ChatMsgEntity)this.data.get(paramInt);
    if (localChatMsgEntity == null)
      return paramView;
    int i = localChatMsgEntity.isComMsg();
    if (paramView == null)
      if (i == 0)
        paramView = this.mInflater.inflate(2130903109, null);
    while (true)
    {
      ViewHolder localViewHolder = new ViewHolder();
      localViewHolder.tvSendTime = ((TextView)paramView.findViewById(2131100042));
      if (i == 0)
        localViewHolder.tvUserName = ((TextView)paramView.findViewById(2131100044));
      localViewHolder.img_photo = ((RoundImageView)paramView.findViewById(2131100043));
      localViewHolder.txt_msg = ((TextView)paramView.findViewById(2131100046));
      localViewHolder.isComMsg = i;
      localViewHolder.iv_gif = ((SimpleDraweeView)paramView.findViewById(2131100047));
      paramView.setTag(localViewHolder);
      String str1 = localChatMsgEntity.getSendtime();
      String str2 = localChatMsgEntity.getNickname();
      String str3 = localChatMsgEntity.getBody();
      if (str1 != null);
      try
      {
        String str5 = DateUtil.intToString(Integer.parseInt(str1), "yyyy-MM-dd HH:mm:ss");
        localViewHolder.tvSendTime.setText(str5);
        if ("3".equals(localChatMsgEntity.getMessagetype()))
        {
          localViewHolder.iv_gif.setVisibility(0);
          localViewHolder.txt_msg.setVisibility(8);
          AbstractDraweeController localAbstractDraweeController = ((PipelineDraweeControllerBuilder)Fresco.newDraweeControllerBuilder().setUri("asset:///" + str3).setAutoPlayAnimations(true)).build();
          localViewHolder.iv_gif.setController(localAbstractDraweeController);
          System.out.println("设置了uriasset:///" + str3);
          if (i != 0)
            break label392;
          localViewHolder.tvUserName.setText(str2);
          return paramView;
          paramView = this.mInflater.inflate(2130903111, null);
          continue;
          localViewHolder = (ViewHolder)paramView.getTag();
        }
      }
      catch (NumberFormatException localNumberFormatException)
      {
        while (true)
        {
          localNumberFormatException.printStackTrace();
          continue;
          localViewHolder.iv_gif.setVisibility(8);
          localViewHolder.txt_msg.setVisibility(0);
          localViewHolder.txt_msg.setText(str3);
          continue;
          label392: String str4 = localChatMsgEntity.getPicurl();
          if (!"".equals(str4))
            UiUtil.loadAndSetPhoto(localViewHolder.img_photo, str4);
          else
            LogUtils.e(TAG, "picUrl为空");
        }
      }
    }
  }

  public int getViewTypeCount()
  {
    return 2;
  }

  public void setCount(int paramInt)
  {
    this.count = paramInt;
  }

  public void setData(List<ChatMsgEntity> paramList)
  {
    this.data = paramList;
  }

  public static abstract interface IMsgViewType
  {
    public static final int IMVT_COM_MSG = 0;
    public static final int IMVT_TO_MSG = 1;
  }

  static class ViewHolder
  {
    public RoundImageView img_photo;
    public int isComMsg;
    public SimpleDraweeView iv_gif;
    public TextView tvSendTime;
    public TextView tvUserName;
    public TextView txt_msg;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.adapter.ChatMsgViewAdpater
 * JD-Core Version:    0.6.2
 */